import Vue from "vue";
import VueRouter from "vue-router";
const { APP } = require("../config/index");
Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/main",
  },

  {
    path: "/main",
    component: () => import("../main.vue"),
    children: [
      {
        path: "/activity",
        name: "activity",
        component: () => import("../views/activity/index.vue"),
        meta: {
          title: "活动管理",
        },
      },
      {
        path: "/test",
        name: "test",
        component: () => import("../views/test/index"),
        meta: {
          title: "测试",
        },
      },
      {
        path: "/talent",
        name: "talent",
        component: () => import("../views/talent/index.vue"),
        meta: {
          title: "达人列表",
        },
      },
      {
        path: "/talentAudit",
        name: "talentAudit",
        component: () => import("../views/talent/talentAudit.vue"),
        meta: {
          title: "达人审核",
        },
      },
      {
        path: "/club",
        name: "club",
        component: () => import("../views/club/index.vue"),
        meta: {
          title: "社团列表",
        },
      },
      {
        path: "/clubActive",
        name: "clubActive",
        component: () => import("../views/club/clubActive.vue"),
        meta: {
          title: "社团详情",
        },
      },
      {
        path: "/clubAudit",
        name: "clubAudit",
        component: () => import("../views/club/clubAudit.vue"),
        meta: {
          title: "加入社团审核",
        },
      },
      {
        path: "/miniApply",
        name: "miniApply",
        component: () => import("../views/miniApply/index.vue"),
        meta: {
          title: "微项目申请管理",
        },
      },
      {
        path: "/wish",
        name: "wish",
        component: () => import("../views/wish/index.vue"),
        meta: {
          title: "小小心愿",
        },
      },
      {
        path: "/business",
        name: "business",
        component: () => import("../views/business/index.vue"),
        meta: {
          title: "商圈联盟",
        },
      },
      //  {
      //     path: '/scoreManage',
      //     name: 'scoreManage',
      //     component: () => import('../views/scoreManage/index.vue'),
      //     meta: {
      //         title: '积分管理',
      //     },
      // },
      {
        path: "/scoreRanking",
        name: "scoreRanking",
        component: () => import("../views/scoreRanking/index.vue"),
        meta: {
          title: "积分排名",
        },
      },
      {
        path: "/userScore",
        name: "userScore",
        component: () => import("../views/scoreRanking/userScore.vue"),
        meta: {
          title: "查看详情",
        },
      },
      {
        path: "/scoreMoney",
        name: "scoreMoney",
        component: () => import("../views/scoreMoney/index.vue"),
        meta: {
          title: "积分流水",
        },
      },
      {
        path: "/scoreConfig",
        name: "scoreConfig",
        component: () => import("../views/scoreConfig/index.vue"),
        meta: {
          title: "积分配置",
        },
      },
      {
        path: "/neighbourhood",
        name: "neighbourhood",
        component: () => import("../views/neighbourhood/index.vue"),
        meta: {
          title: "邻里圈",
        },
      },
      {
        path: "/venue",
        name: "venue",
        component: () => import("../views/venue/index.vue"),
        meta: {
          title: "场馆预约",
        },
      },
      {
        path: "/peopleArchive",
        name: "peopleArchive",
        component: () => import("../views/peopleArchive/index.vue"),
        meta: {
          title: "居民积分管理",
        },
      },
    ],
  },
];

const router = new VueRouter({
  mode: "hash",
  base: process.env.BASE_URL,
  routes,
});
// 路由守卫
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title;
  } else {
    document.title = APP.title;
  }
  // if (to.path === '/login') {
  //     next();
  // } else {
  //     let token = sessionStorage.getItem('access_token');
  //     if (token == null || token == '') {
  //         next('/login');
  //     } else {
  //         next();
  //     }
  // }
  next();
});
export default router;
